package com.winit.indexing.model;

import com.alibaba.fastjson.JSONObject;
import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.data.cassandra.mapping.Column;
import org.springframework.data.cassandra.mapping.PrimaryKeyClass;
import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
import org.springframework.util.StringUtils;

import java.io.Serializable;

@PrimaryKeyClass
public class IndexingId implements Serializable{
    //index_ group 索引名  一种索引一种名称
    @PrimaryKeyColumn(name = "index_group", type = PrimaryKeyType.PARTITIONED)
    @Column("index_group")
    private String indexGroup;
    //过滤标签
    @PrimaryKeyColumn( name = "filter_tag")
//    @Column("filter_tag")
    private String filterTag;


    public IndexingId(){

    }

    public IndexingId(String indexGroup, String filterTag){
        this.indexGroup = indexGroup;
        this.filterTag = filterTag;
    }

    public String getIndexGroup() {
        return indexGroup;
    }

    public void setIndexGroup(String indexGroup) {
        this.indexGroup = indexGroup;
    }

    public String getFilterTag() {
        return filterTag;
    }

    public void setFilterTag(String filterTag) {
        this.filterTag = filterTag;
    }

    public boolean isValid(){
        return !(StringUtils.isEmpty(indexGroup) || StringUtils.isEmpty(filterTag));
    }

    @Override
    public String toString(){
        return JSONObject.toJSONString(this);
    }
}
